
package com.tsingtree.sys.core.exception.page;

import com.tsingtree.sys.core.constant.Const;
import com.tsingtree.sys.modular.system.config.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 全局的控制器
 *
 * @author jagger
 */
@Controller
@RequestMapping("/global")
public class GlobalController {

    @Autowired
    private Config config;

    /**
     * 跳转到404页面
     *
     * @author jagger
     */
    @RequestMapping(path = "/error")
    public String errorPage() {
        return "/404.html";
    }

    /**
     * 跳转到session超时页面
     *
     * @author jagger
     */
    @RequestMapping(path = "/sessionError")
    public String errorPageInfo(Model model) {
        model.addAttribute("tips", "登陆超时，请您重新登陆！");
        model.addAttribute("account", config.isTest? Const.DEFAULT_ACCOUNT : "");
        model.addAttribute("pwd", config.isTest? Const.DEFAULT_PWD : "");
        return "/login.html";
    }
}
